module icon(
	input clock, rst,
	input [7:0] loc_x,
	input [7:0] loc_y,
	input [7:0] bot_info,
	input [9:0]	pixel_row, pixel_column,
	output reg [1:0] icon_pixel
);

wire [1:0] icon;
wire [9:0] scaled_loc_x, scaled_loc_y,loc1,loc2;
wire [11:0] address;
reg tick=0;
reg [24:0] ck_count = 0;

assign loc1 = (pixel_row  - scaled_loc_y+28);
assign loc2 = (pixel_column - scaled_loc_x+14);

assign scaled_loc_x = (loc_x << 2);
assign scaled_loc_y = (loc_y << 2);
//assign com_botinfo = (2- bot_info[2:0]);

assign address = {bot_info[2:0],tick,loc1[4:1],loc2[4:1]};

bus_mem rb (
  .clka(clock), // input clka
  .addra(address), // input [11 : 0] addra
  .douta(icon) // output [1 : 0] douta
);

always @(posedge clock)
begin
 if ( ck_count <= 25'd12_499_999)
    tick = 0;
else 
	 tick = 1;
	 
   if ( ck_count == 25'd24_999_999)
	ck_count = 0;	
else 
    ck_count = ck_count + 1;
end

always @(*)
begin
	
	if (rst)
		icon_pixel = 2'b00;
	else
	begin	
		if((loc1>=0 && loc1<32) && (loc2>=0 && loc2<32)) 	
		//if(((pixel_row >= scaled_loc_y-6) && (pixel_row < scaled_loc_y+10)) && ((pixel_column >= scaled_loc_x-6) && (pixel_column < scaled_loc_x + 10)))
		//if(((pixel_row >= scaled_loc_y) && (pixel_row < scaled_loc_y+16)) && ((pixel_column >= scaled_loc_x) && (pixel_column < scaled_loc_x + 16)))
			icon_pixel = icon;
		else
			icon_pixel = 2'b00;
	end 
end 
endmodule 
